package com.vincent.sciinfo.mapper;

import com.vincent.sciinfo.pojo.Project;
import com.vincent.sciinfo.pojo.ProjectExample;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ProjectMapper {
    long countByExample(ProjectExample example);

    int deleteByExample(ProjectExample example);

    int deleteByPrimaryKey(String resultuuid);

    int insert(Project record);

    int insertSelective(Project record);

    List<Project> selectByExample(ProjectExample example);

    Project selectByPrimaryKey(String resultuuid);

    int updateByExampleSelective(@Param("record") Project record, @Param("example") ProjectExample example);

    int updateByExample(@Param("record") Project record, @Param("example") ProjectExample example);

    int updateByPrimaryKeySelective(Project record);

    int updateByPrimaryKey(Project record);

    @Update("update project set score = #{score} where resultUUid = #{projectId}")
    int scoreProject(@Param("projectId") String projectId, @Param("score") int score);

    @Update("update project \n" +
            "set score = (select score from scorestandard where name = ( select a.projectRank from (select projectRank from project where resultUUid = #{resultUUid}) AS a ) )\n" +
            "where resultUUid = #{resultUUid}\n")
    int updateProjectScoreByType(@Param("resultUUid") String projectId);
}